
from flask import Flask

from flask_cors import CORS
from utils.jwt_auth import jwt_authentication
from models import db
from views.users import user_bp
from views.Courses import course_bp
from views import init_bp
from views.VIP import vip_bp


def create_flask_app(config):
    app = Flask(__name__)
    app.config.from_object(config)
    db.init_app(app)
    cors = CORS(app)

    # 注册蓝图
    app.register_blueprint(user_bp)
    app.register_blueprint(init_bp)
    app.register_blueprint(course_bp)
    app.register_blueprint(vip_bp)

    app.before_request(jwt_authentication)

    return app
